package cn.catsdad.base.entity;

import cn.catsdad.tenant.listener.TenantListener;
import cn.catsdad.util.AuthUtil;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 租户实体，限制所有租户数据必须有租户id
 *
 * @author xuyl
 * @version 1.0 2024/6/23
 */
@EqualsAndHashCode(callSuper = true)
@Data
@MappedSuperclass
@EntityListeners(TenantListener.class)
public abstract class BaseTenantEntity extends BaseEntity {

    public BaseTenantEntity() {
        this.tenantId = AuthUtil.getCurrentTenantId();
    }

    /**
     * 租户id
     */
    private Long tenantId;

}
